Connectivity Software User's Guide and Reference
Examples - OPC Classic Specialized - Kepware KEPServerEX - Get multiple property values

.NET

// This KEPServerEX example shows how to get value of multiple OPC properties, and handle errors.
//
// Note that some properties may not have a useful value initially (e.g. until the item is activated in a group).
//
// Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

namespace DocExamples.Specialized
{
    partial class Kepware_KEPServerEX
    {
        public static void GetMultiplePropertyValues()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            ServerDescriptor serverDescriptor = "Kepware.KEPServerEX.V6";

            // Get the values of Timestamp and AccessRights properties of two items.
            ValueResult[] results = client.GetMultiplePropertyValues(new[]
            {
                new DAPropertyArguments(serverDescriptor, "Simulation Examples.Functions.Random1", DAPropertyDescriptor.Timestamp),
                new DAPropertyArguments(serverDescriptor, "Simulation Examples.Functions.Random1", DAPropertyDescriptor.AccessRights),
                new DAPropertyArguments(serverDescriptor, "Simulation Examples.Functions.Ramp1", DAPropertyDescriptor.Timestamp),
                new DAPropertyArguments(serverDescriptor, "Simulation Examples.Functions.Ramp1", DAPropertyDescriptor.AccessRights)
            });

            for (int i = 0; i < results.Length; i++)
            {
                ValueResult valueResult = results[i];
                if (valueResult.Exception is null)
                    Console.WriteLine($"results({i}).Value: {valueResult.Value}");
                else
                    Console.WriteLine($"results({i}).Exception.Message: {valueResult.Exception.Message}");
            }
        }
    }
}